<?php include(VIEWSPATH."/common/header.php") ?>
<script>
	$(document).ready(function(){
		
	});
	function show_num(id,val){
		$("#lbl_val_num_"+ id ).html(val);
		$("#view_number_"+id).show();
		$("#edit_number_"+id).hide();
	}
	function edit_num(id,val){
		$("#txt_val_num_"+ id ).val(val);
		$("#view_number_"+id).hide();
		$("#edit_number_"+id).show();
	}	
	function update_num(id,id_val){
		
		$.ajax({
			url:"<?php echo base_url('user/update_num');?>",
			dataType :"json",
			data:{
				'ma_aodai': id ,
				'soluong' :$("#"+id_val).val()
			},
			 type: "POST",
			success:function(data){
				console.log(data.status);
				if (data.status == 'success'){
					show_num(id,$("#"+id_val).val());
					$("#id_tongtien").html(data.tongtien);
				}				
			}
		});
	}		
</script>

Các sản phẩm đã chọn
<table  class="list_product" cellspacing="0" width="500">
	<tr>
		<th>STT</th>
		<th><?php echo lang('image')?></th>
		<th><?php echo lang('price')?></th>
		<th><?php echo lang('note')?></th>
		<th><?php echo lang('quantity')?></th>
	</tr>
	<?php $i =1 ?>
	<?php $tongtien =0 ?>
	<?php	foreach ($info as $row) { ?>
	<tr>
		<td align="center"><?php echo $i ?></td>
		<td align="center"><img height="60" class="img_list"  id="img_small_<?php echo $row -> id ?>" src="<?php echo base_url('/assets/image/aodai/'.($row -> id %10)."/".$row->image); ?>"></img></td>
		<td align="right"> <?php  echo preg_replace("/^(\d+)(\d\d\d)/i", "$1,$2", $row -> price);  ?> <span class="money">VNĐ</span></td>
		<td align="center"> <?php echo ($row->note !='' ? $row->note : '--') ?></td>
		<td align="right" width="150">
			<div id="view_number_<?php echo $row -> id ?>">
				<span id="lbl_val_num_<?php echo $row -> id ?>" ><?php echo $row->soluong ?></span>
				<span class="button" id="btn_edit_num" value="<?php echo $row -> id ?>" onclick="edit_num('<?php echo $row -> id ?>','<?php echo $row->soluong ?>')"><?php echo lang('edit')?></span>
			</div> 
			<div id="edit_number_<?php echo $row -> id ?>" style="display:none;">
				<input style="width:50px;" type="text" id="txt_val_num_<?php echo $row -> id ?>" value="<?php echo $row->soluong ?>"></input>
				<span class="button" id="btn_update_num" onclick="update_num('<?php echo $row -> id ?>','txt_val_num_<?php echo $row->id ?>')"><?php echo lang('update')?></span><br>
				<span class="button" id="btn_cancel_edit_num" onclick="show_num('<?php echo $row -> id ?>','<?php echo $row->soluong ?>')"><?php echo lang('cancel')?></span>
			</div> 
		</td>
		<?php $i = $i + 1 ?>
		<?php $tongtien = $tongtien  + ($row->price * $row->soluong) ?>
	</tr>
	<?php   }?>
	<tr>
		<td colspan="5" align="right">
			<b><?php echo lang('total_price')?> : <span id="id_tongtien"><?php echo  preg_replace("/^(\d+)(\d\d\d)/i", "$1,$2", $tongtien) ;?></span></b>
		</td>
	</tr>
</table>
<div style="text-align:center;width:500px;">
	<span class="button" onclick="redirect_page('<?php echo base_url('product/home/') ?>')"><?php echo lang('continue')?></span>
	<span class="button" id="btn_buy" onclick="redirect_page('<?php echo base_url('user/order/') ?>')" ><?php echo lang('pay')?></span>
</div>

<?php include(VIEWSPATH."/common/footer.php") ?>